import { CREATE_TYPE, EXCHANGE, MATERIAL_CREATE_TYPE, MATERIAL_PLATFORM, MATERIAL_TYPE_MAPS, USER_QUERY_LEVEL } from "@/config/enum";

export interface MaterialEntity extends BusinessModelEntity {
  Name: string;
  Path: string;
  Md5: string;
  FileType: string; // 文件格式: png、jpg、jpeg、gif、mp4
  Type: MATERIAL_TYPE_MAPS; // 文件类型
  GroupList: any[]; // 组合素材，预留字段
  AspectRatio: number; // 宽高比,1为横版，2为竖版
  FileSize: number;
  Width: number;
  Height: number;
  Duration: number;
  Resolution: number; // 分辨率，单位p
  VideoBitRate: number; // 视频码率，单位kbps
  VideoFrameRate: number; // 视频帧率，单位fps
  AudioBitRate: number; // 音频码率，单位kbps
  CreateType: MATERIAL_CREATE_TYPE;
  LabelIds: number[]; // 标签ID
  UploadTime: number; // 上传日期
  Platform: MATERIAL_PLATFORM; // 素材平台
  SubPlatform: MATERIAL_SUB_PLATFORM; // 素材子平台
  Frame: {
    // 视频截图
    [EXCHANGE.TOUTIAO]: Frame[];
    [EXCHANGE.KUAISHOU]: Frame[];
  };
  ParentId: number; // 压缩文件对应的源文件id
  IsCompress: boolean; // 是否是压缩文件
  IsOss: boolean; // 是否Oss 文件
  SyncOss: boolean; // 是否已经同步文件到oss
  Audits: MaterialAudit[]; // 审核信息
  AuditAllCount: number; // 总的拒审个数
  AuditAdxCount: AuditAdxCount; // 各个渠道的拒审个数
}

export interface ChangeMaterialDto extends MaterialEntity {
  TkPreviewUrl: string; // 预览url
  TkPreviewstatus: TK_TASK_STATUS;
}

export interface AuditAdxCount {
  [prop: string]: number;
}

export interface MaterialAudit {
  CampaignId: number; // 广告ID
  Reasons: string[]; // 拒绝原因和审核建议，会有多条
}

export interface Frame {
  Path: string; // 截图路径
  ExternalId?: number; // 截图的渠道三方id
}

// 横竖屏
export enum ASPECT_RATIO {
  HORIZONTAL = 1,
  VERTICAL,
  ALL = 4,
}

// 审核状态
export enum MATERIAL_AUDIT_STATUS {
  PASS = 1,
  NOT_PASS,
  UNKNOWN,
}

// 素材评价
export enum QUALITY {
  PRETTY = 1,
  COMMON,
  LOW,
}

export const QUALITY_TEXT_MAP = {
  [QUALITY.PRETTY]: "优质",
  [QUALITY.COMMON]: "普通",
  [QUALITY.LOW]: "低效",
};

export interface MaterialSizeListItem {
  width: number;
  height: number;
}

// 高级过滤
export interface FilterDto {
  field: string;
  operator: string;
  value: number;
  operator2?: string;
  value2?: number;
}

export interface auditItem {
  adxId?: number;
  count: number;
  eater?: boolean;
  isGreater?: boolean;
}

export interface MaterialListDto extends BaseGridListDto {
  All?: boolean;
  userId?: number;
  adxIds?: EXCHANGE[];
  ids?: number[];
  WithPreview?: boolean;
  WithRelateCreative?: boolean;
  WithRelateAccount?: boolean;
  WithRelCampaign?: boolean;
  NotQueryAmount?: boolean;
  aspectRatio?: number;
  duration?: number[];
  sizeList?: MaterialSizeListItem[];
  createType?: MATERIAL_CREATE_TYPE;
  uploaderIds?: number[];
  uploadDate?: { beginDate: number; endDate: number };
  fileType?: string[];
  type?: MATERIAL_TYPE_MAPS;
  extensions?: string;
  size?: number;
  width?: number;
  height?: number;
  accountId?: number;
  accountIdsOfAnd?: number[];
  accountIdsOfOr?: number[];
  labelIds?: number[];
  subPlatform?: MATERIAL_SUB_PLATFORM;
  filter?: FilterDto[];
  isSquare?: boolean;
  auditAllCount?: auditItem;
  auditAdxCount?: auditItem[];
  awemeId?: string;
  productId?: string;
  externalIds?: string[];
  folderIds?: number[];
  findFolder?: boolean;
  labelCollectType?: number;
  userQueryLevel?: USER_QUERY_LEVEL;
  order?: string;
  page?: number;
  limit?: number;
  word?: string;
}

// 素材子平台
export enum MATERIAL_SUB_PLATFORM {
  // 快手
  SUZAO = 1000901, // 素造（弃用）
  KS_0, // 自上传
  KS_1, // 开眼
  KS_2, // 素造
  KS_7 = 1000905, // 聚星视频
  KS_4 = 1000906, // MAPI
  KS_10 = 1000910, // 个人主页,
  KS_11 = 1000911, // 供应商自制,
  // 头条
  AD_SITE = 1000601, // ad后台本地上传
  CREATIVE_CENTER, // 创意中心
  OPEN_API, // 开放平台
  SUPPLIER, // 即合视频
  VIDEO_CAPTURE, // 易拍视频
  ACCOUNT_PUSH, // 推送视频
  STAR, // 星图视频
  CEWEBRITY_VIDEO, // 达人视频
  OTHERS, // 其他来源
  TT_AWEME = 1000610, // 抖音来源
  // 广点通
  SOURCE_TYPE_UNSUPPORTED = 1000101, // 其他上传方式
  SOURCE_TYPE_LOCAL, // 通过投放端本地自行上传
  SOURCE_TYPE_MUSE, // 妙思智能制图工具
  SOURCE_TYPE_API, // 通过 Marketing API 上传
  SOURCE_TYPE_QUICK_DRAW, // 快速制图工具
  SOURCE_TYPE_VIDEO_SNAPSHOTS, // 视频截图
  SOURCE_TYPE_TCC, // 腾讯创意订制平台制作
  SOURCE_TYPE_VIDEO_MAKER_XSJ, // 小视界视频制作工具
  // 千川
  QC_AWEME = 1100601, // 抖音
  QC_E_COMMERCE, // 巨量千川
  QC_BP, // 巨量纵横
  QC_ARTHUR, // 亚瑟
  QC_STAR, // 星图&即合
  QC_VIDEO_CAPTURE, // 易拍
  QC_CREATIVE_CENTER, // 创意PC
  QC_LIVE_HIGHLIGHT, // 直播剪辑
  QC_TADA, // tada
  QC_JI_CHUANG = 1100612, // 即创
  // 快手磁力金牛
  JN_0 = 1100901, // 自上传
  JN_1, // 开眼
  JN_2, // 素造
  JN_4 = 1100905, // MAPI
  JN_7 = 1100908, // 快接单
  JN_8, // LA-CRM上传
  JN_10 = 1100911, // 个人主页
  JN_11, // 代理商自制
}

// 特看预览任务的状态
export enum TK_TASK_STATUS {
  NotStarted = 0, // 未开始
  Ongoing = 1, // 进行中
  Success = 2, // 完成
  Fail = 3, // 失败
}
export interface ExportCol {
  field: string;
  text: string;
}

// 适用与广告管理 -> 广告推广
export interface BaseGridListDto {
  Metrics?: string[];
  ExportCols?: ExportCol[];
  WithLevel?: boolean;
  WithMaterial?: boolean;
  OrderBy?: string;
  AccountId?: number;
  AccountIds?: number[];
  PlanId?: number;
  CampaignId?: number;
  BusinessId?: number;
  AdxId?: number;
  AdxIds?: number[];
  CreateType?: CREATE_TYPE;
  UserIds?: number[];
  NeedTimeSeries?: boolean;
  isMultiProject?: boolean;
  userIds?: number[];
}

export enum AUTO_SYNC_MATERIAL {
  NO_AUTO_SYNC = 1,
  AUTO_SYNC,
}

export interface DelMaterialDto {
  id: number[];
  type?: MATERIAL_TYPE_MAPS;
}
